package lhdx3;

public class Xscz {
    String name;
    String dirTeacher;
    String startDate;

    String[] stus = new String[30];

    public void add(String stuname) {
        for (int i = 0; i < stus.length; i++) {
            if (stus[0]==null){
                stus[0]=stuname;
                return;
            }
            if (stus[i] == null) {
                for (int j=0;j<i;j++) {
                    if (stus[j].equals(stuname)) {
                        System.out.println("有重复，输入失败！");
                        return;
                    }
                }
                if (stus[i]!=stuname){
                     stus[i]=stuname;
                     return;
                }
            }
        }
        System.out.println("人已满");
    }

    public void showInformation() {
        System.out.println("班级信息如下：");
        for (int i = 0; i < stus.length; i++) {
            if (stus[i] == null)
                break;
            System.out.print(stus[i] + "   ");
        }
        System.out.println("");
    }

    public boolean searchName(String name) {
        for (int i = 0; i < stus.length; i++) {
            if (stus[i] == null) {
                return false;
            }
            if (stus[i].equals(name))
                return true;
        }
        return false;
    }


}
